<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/tenant/user/modifyLogo.js"></script>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">修改Logo</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form id="frmLogo" name="frmLogo">
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">logo：</label>
                            <div class="col-sm-8">
                                <div id="">
                                    <c:choose>
                                        <c:when test="${tenantLogoImg!=null && tenantLogoImg!=''}">
                                            <div id="">
                                                <img id="tenantLogoImg" src="${uploadPath}${tenantLogoImg}"
                                                     width="400px" height="160px">
                                                <input type="file" id="file1" name="file1"/>
                                            </div>
                                        </c:when>
                                        <c:otherwise>
                                            <div id="">
                                                <img id="tenantLogoImg" src="${ctx}/statics/img/upload-img.png"
                                                     style="position: relative" width="400px" height="160px">
                                                <input type="file" id="file1" name="file1"/>
                                            </div>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                                <span>图片尺寸建议为：<span class="text-danger">400px*160px</span></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-success">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    $("#file1").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        var fileSize = $(this)[0].files[0].size
        if (objUrl) {
            if (fileSize > (1024 * 100)) {
                layer.msg('请上传小于100KB的图片！');
                $(this).val("");
                return
            }
            $("#tenantLogoImg").attr("src", objUrl);

        }
    });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

    modifyLogo.init();
</script>
</body>
</html>
